package edu.fiu.cis.personalize.server.berkDB;

import java.util.ResourceBundle;

import javax.servlet.ServletConfig;

public final class FileResolver {
	private boolean initialized = false;
	private ResourceBundle resourceBundle = null;
	private String basePath;

	public FileResolver(ServletConfig config) {
		if (initialized)
			return;
		basePath = "war/";

		if (config != null) {
			basePath = config.getServletContext().getRealPath("/");
		}

		resourceBundle = ResourceBundle
				.getBundle("edu.fiu.cis.personalize.server.berkDB.FileLocation");
		initialized = true;

	}

	private String path(String key) {
		return basePath + resourceBundle.getString(key);
	}

	public String getBerkleyDBDir() {
		return path("berkleyDBDir");
	}

}
